package common;

import java.util.Collection;
import java.util.Hashtable;

import model.AltaRicaConst;
import model.AltaRicaDomain;
import model.AltaRicaNode;

public class AltaRicaModel {
	
	private static Hashtable<String, AltaRicaNode> nodes = new Hashtable<String,AltaRicaNode>();
	private static Hashtable<String, AltaRicaDomain> domains = new Hashtable<String,AltaRicaDomain>();
	private static Hashtable<String, AltaRicaConst> consts = new Hashtable<String,AltaRicaConst>();
	
	
	public static void addNode(AltaRicaNode node) {
		
		nodes.put(node.getName(), node);
	}
	
	public static AltaRicaNode getNode(String id) {
		
		return nodes.get(id);
	}
	
	public static Collection<AltaRicaNode> getNodes() {
		
		return nodes.values();
	}
	
	public static void addDomain(AltaRicaDomain domain) {
		
		domains.put(domain.getName(), domain);
	}
	
	public static AltaRicaDomain getDomain(String name) {
		
		return domains.get(name);
	}
	
	public static Collection<AltaRicaDomain> getDomains() {
		
		return domains.values();
	}
	
	public static void addConst(AltaRicaConst cnst) {
		
		consts.put(cnst.getId(), cnst);
	}
	
	public static AltaRicaConst getConst(String id) {
		
		return consts.get(id);
	}
	
	public static Collection<AltaRicaConst> getConstants() {
		
		return consts.values();
	}
	
	public static String string() {
		
		String str = new String();
		
		for (AltaRicaConst cnst : consts.values()) {
			
			str += cnst.toString() + "\n";
		}
		
		str += "\n"; 
		
		for (AltaRicaDomain domain : domains.values()) {
			
			str += domain.toString() + "\n";
		}
		
		str += "\n";
		
		for (AltaRicaNode node : nodes.values()) {
			str += node.toString();
		}
		
		return str;
	}

}
